﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace sieve_of_eratosthenes_cs
{
    class Program
    {
        static void Main(string[] args)
        {
            const int limit = 99999;
            int[] sievearr;
            sievearr = new int[limit];
            int[] primenumbers;
            primenumbers = new int[limit];
            int primepos = 0;
            int step;
            for (int i = 2; i < limit+2; i++)
                    sievearr[i-2] = i;
            for (int i = 0; i < limit; i++)
            {
                    if (sievearr[i] == 0)
                            continue;
                    step = sievearr[i];
                    for (int x = i+step; x < limit; x += step)
                    {
                            if (sievearr[x] != 0)
                                    sievearr[x] = 0;
                    }
            }
            for (int i = 0; i < limit; i++)
            {
                    if (sievearr[i] != 0)
                    {
                            primenumbers[primepos] = sievearr[i];
                            primepos++;
                    }
            }
            Console.WriteLine(primenumbers[primepos-1]);
        }
    }
}
